/*
 * @name: 企业认证审核
 * @Author: along
 * @Date: 2020-06-02
 */
<template>
    <div class="container hireAuthExamine">
        <!-- tips -->
        <div class="container-tips">
            1 查看营业执照中的公司名称是否与其填写的一致;2 查看其法人身份证件中的姓名是否与营业执照中的法人姓名一致;3 重点查看品牌授权图片以及图中的失效时间以及与其填写的品牌名称是否一致;4 重点查看商标授权书是否为真，以及图中的失效时间
        </div>

        <!-- header -->
        <div class="header-nav">
            <div class="header-left">
                <div class="header-new-box">
                    <el-radio-group
                        v-model="head.status"
                        size="small"
                        @change="getTableData(1)"
                    >
                        <el-radio-button :label="99">
                            全部
                        </el-radio-button>
                        <el-radio-button :label="1">
                            待审核
                        </el-radio-button>
                        <el-radio-button :label="2">
                            审核通过
                        </el-radio-button>
                        <el-radio-button :label="-1">
                            未通过
                        </el-radio-button>
                    </el-radio-group>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">公司名称:</p>
                    <el-input
                        v-model="head.name"
                        placeholder="请输入内容"
                        size="small"
                        clearable
                        suffix-icon="el-icon-search"
                        @change="getTableData(1)"
                        @keyup.native.enter="getTableData(1)"
                    />
                </div>
            </div>
        </div>
        <!-- /header -->

        <!-- table -->
        <el-table
            :data="tableData"
            height="100%"
            style="width: 100%;"
            border
            ref="hireAuthExamine"
        >
            <el-table-column
                type="index"
                width="80"
                label="序号"
                align="center"
                fixed="left"
            />
            <el-table-column
                prop="company_name"
                label="公司名称"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                fixed="left"
            />
            <el-table-column
                prop="qualification_image"
                label="营业执照"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            >
                <template slot-scope="scope">
                    <p
                        class="cursor-font"
                        @click="fnShowPreview(scope.row.qualification_image)"
                    >
                        点击查看
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="legal_name"
                label="法人姓名"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="legal_id_card_image"
                label="法人身份证"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                :width="130"
            >
                <template slot-scope="scope">
                    <p
                        v-if="scope.row.legal_id_doc_image"
                        class="cursor-font"
                        @click="fnShowPreview([scope.row.legal_id_doc_image])"
                    >
                        点击查看
                    </p>
                    <p
                        v-else
                        class="cursor-font"
                        @click="fnShowPreview([scope.row.legal_id_card_image, scope.row.legal_id_card_national_image])"
                    >
                        点击查看
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="brand_name"
                label="品牌名称"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="brand_authorize_images"
                label="品牌授权"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            >
                <template slot-scope="scope">
                    <p
                        class="cursor-font"
                        @click="fnShowPreview(scope.row.brand_authorize_images)"
                        v-if="scope.row.brand_authorize_images"
                    >
                        点击查看
                    </p>
                    <p v-else>
                        --
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="brand_authorize_expire_time"
                label="授权失效时间"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                :width="130"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.brand_authorize_expire_time">
                        {{ scope.row.brand_authorize_expire_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm') }}
                    </p>
                    <p v-else>
                        --
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="brand_logo_reg_no"
                label="商标注册号"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                :width="130"
            />
            <el-table-column
                prop="brand_logo_reg_images"
                label="商标注册证明"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                :width="130"
            >
                <template slot-scope="scope">
                    <p
                        class="cursor-font"
                        @click="fnShowPreview(scope.row.brand_logo_reg_images)"
                        v-if="scope.row.brand_logo_reg_images"
                    >
                        点击查看
                    </p>
                    <p v-else>
                        --
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="brand_logo_reg_expire_time"
                label="证明失效时间"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                :width="130"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.brand_logo_reg_expire_time">
                        {{ scope.row.brand_logo_reg_expire_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm') }}
                    </p>
                    <p v-else>
                        --
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="qualification_other_images"
                label="相关资质"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            >
                <template slot-scope="scope">
                    <p
                        class="cursor-font"
                        @click="fnShowPreview(scope.row.qualification_other_images)"
                        v-if="scope.row.qualification_other_images"
                    >
                        点击查看
                    </p>
                    <p v-else>
                        --
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="shop_type"
                label="店铺类型"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.shop_type == 1">普通店</p>
                    <p v-if="scope.row.shop_type == 2">专营店</p>
                    <p v-if="scope.row.shop_type == 3">专卖店</p>
                    <p v-if="scope.row.shop_type == 4">旗舰店</p>
                    <p v-if="scope.row.shop_type == 5">官方旗舰店</p>
                </template>
            </el-table-column>
            <el-table-column
                prop="shop_name"
                label="店铺名称"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="goods_type_name"
                label="店铺主营类目"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                :width="140"
            />
            <el-table-column
                prop="company_size_str"
                label="公司规模"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="category_parent"
                label="公司行业"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.category_parent && scope.row.category">
                        {{ scope.row.category_parent + '-' + scope.row.category }}
                    </p>
                    <p v-else>
                        --
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="contact_email"
                label="联系邮箱"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="contact_address"
                label="联系地址"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="company_intro"
                label="公司简介"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="verify"
                label="审核状态"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                fixed="right"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.verify == 1">待审核</p>
                    <p v-if="scope.row.verify == 2">审核通过</p>
                    <p v-if="scope.row.verify == -1">审核不通过</p>
                </template>
            </el-table-column>
            <el-table-column
                prop="submit_time"
                label="提交时间"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                fixed="right"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.submit_time">
                        {{ scope.row.submit_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm') }}
                    </p>
                    <p v-else>
                        --
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                prop="verify_fail_reason"
                label="不通过理由"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                fixed="right"
                :width="130"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.verify_fail_reason">
                        {{ scope.row.verify_fail_reason }}
                    </p>
                    <p v-else>
                        --
                    </p>
                </template>
            </el-table-column>
            <el-table-column
                label="操作"
                align="center"
                fixed="right"
            >
                <template slot-scope="scope">
                    <el-button
                        type="text"
                        class="curse-add"
                        :disabled="scope.row.verify == 2 || scope.row.verify == -1"
                        @click="fnAdopt(scope.row)"
                    >
                        通过
                    </el-button>
                    <el-button
                        type="text"
                        class="curse-add"
                        :disabled="scope.row.verify == 2 || scope.row.verify == -1"
                        @click="fnNoAdopt(scope.row)"
                    >
                        不通过
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <!-- /table -->

        <!-- /分页 -->
        <div class="pagination-wrapper clearfix">
            <el-pagination
                background
                layout="total, prev, pager, next"
                :current-page.sync="page.now_page"
                :total="page.total_count"
                :page-size="page.page_size"
                @current-change="getTableData"
            />
        </div>

        <!-- 图片预览 -->
        <img-preview ref="preview" />
    </div>
</template>

<script>
import imgPreview from '@/components/common/img-preview';
import { back } from '@/mixin/back';
export default {
    /**
     * @param   {Object}     head                       筛选字段
     * @param   {Object}     page                       分页
     * @param   {Array}      tableData                  数据列表
     * @param   {OBject}     authResult                 权限列表
     */
    mixins: [back],
    components: {
        imgPreview
    },
    data () {
        return {
            head: {
                status: 99,
                name: ''
            },
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 0
            },
            tableData: [],
            authResult: {}
        };
    },
    filters: {},
    computed: {},
    watch: {},
    mounted () {
        this.$store.commit('SET_HEADER', [{title: '官网'},{title: '客户审核与合同'},{title: '企业认证审核'}]);
        this.authResult = this.$route.meta.authResult;
        this.getTableData();
    },
    methods: {
        /**
         * 获取表格数据
         */
        getTableData (page) {
            this.$post('/student/hire_user_company_verify%5Cget_list', {
                page_id: page || this.page.now_page,
                company_name: this.head.name,
                verify: this.head.status
            }, resp => {
                if (resp.code == 1) {
                    this.tableData = resp.data.list;
                    this.page.now_page = resp.data.page.now_page;
                    this.page.total_count = resp.data.page.total_count;
                    this.page.page_size = resp.data.page.page_size;
                }
            });
        },

        /**
         * 通过
         */
        fnAdopt (row) {
            this.$confirm('是否通过，一旦通过不可取消?', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/hire_user_company_verify%5Cverify',{
                    verify_no: row.verify_no,
                    verify: 2
                },resp => {
                    if(resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg
                        });
                    }
                });
            });
        },

        /**
         * 不通过
         */
        fnNoAdopt (row) {
            this.$prompt('请输入不通过的理由', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
            }).then(({ value }) => {
                this.$post('/student/hire_user_company_verify%5Cverify',{
                    verify_no: row.verify_no,
                    verify: -1,
                    verify_fail_reason: value
                },resp => {
                    if(resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg
                        });
                    }
                });
            });
        },

        /**
         * 查看图片
         */
        fnShowPreview(images) {
            if(images && Object.prototype.toString.call(images) == '[object String]') {
                if(images == '') {
                    this.$message({
                        type: 'warning',
                        message: '暂无图片'
                    });
                    return;
                }
                this.$refs.preview.show([
                    images
                ]);
            } else if (images && Object.prototype.toString.call(images) == '[object Array]') {
                this.$refs.preview.show(images);
            } else {
                this.$message({
                    type: 'warning',
                    message: '图片类型错误'
                });
            }
        },

        /**
         * 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        }
    }
};
</script>

<style lang="less" scoped>
    .container {
        background-color: #fff;
        padding: 10px 15px 5px 15px;
        display: flex;
        flex-direction: column;
        position: relative;
        width: 100%;
        .container-tips {
            padding: 4px 10px;
            font-size: 12px;
            background-color: #fdf6ec;
            color: #e6a23c;
            border-color: #faecd8;
            border-width: 1px;
            border-style: solid;
            box-sizing: border-box;
            line-height: 22px;
            margin-bottom: 10px;
            border-radius: 5px;
        }
        .header-nav {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            .header-left, .header-right {
                display: flex;
                align-items: center;
            }
            .header-new-box {
                display: flex;
                margin-right: 15px;
                align-items: center;
                color: #606266;
                margin-bottom: 10px;
                &-title {
                    margin-right: 2px;
                    white-space: nowrap;
                }
            }
        }
        /* 表单 */
        .scope-price {
            width: 50px;
            height: 50px;
        }
        /* 字体高亮 */
        .cursor-font {
            color: rgb(64, 158, 255);
            cursor: pointer;
        }
        /* 分页 */
        .pagination-wrapper {
            padding-top: 10px;
            padding-bottom: 10px;
            .el-pagination {
                float: right;
                padding: 0;
                background-color: transparent;
            }
        }
    }
    /* 排序 */
    .sort-wrap {
        display: flex;
        align-items: center;
        cursor: pointer;
        .sort-spliter {
            width: 1px;
            height: 12px;
            background: rgba(235, 235, 235, 1);
            margin: 0 10px;
            }
            .btn-sort {
            font-size: 14px;
            line-height: 1;
            color: #ccc;
            &:hover {
                color: #20a0ff;
            }
        }
    }
    .el-button-left {
        margin-left: 40px;
    }
    .el-button-right {
        margin-right: 10px;
    }
</style>
<style lang="less">
    .hireAuthExamine{
        .el-table__body-wrapper .el-table__body .el-table__row td {
            border-right: none;
        }
        .el-table__header-wrapper .el-table__header .has-gutter tr th {
            border-right: none;
        }
        .el-table .el-table_1_column_6  .cell {
            position: relative;
        }
        .el-range-editor--small .el-range-separator{
            padding: 0 1px !important;
        }
    }
</style>
